package com.it.myd.help;

import com.it.myd.bean.box.world.Ability;
import com.it.myd.bean.box.world.Item;
import com.it.myd.bean.box.world.Prefix;

import java.util.Random;

public class PrefixLoader {

    public Prefix randomPrefix(Item item){
        Prefix prefix = item.getPrefix();
        if("tool".equals(prefix.getType())){
            prefix = ToolPrefix(prefix);
        }
        return prefix;
    }

    public Prefix ToolPrefix(Prefix prefix){
        Ability a = prefix.getAbility();
        if(a != null){
            Random random = new Random();
            int num = random.nextInt(10) + 1;
            if(num>8){
                prefix.setLevel("t1");
                prefix.setName("良好的");
                a.setStrength(1);
                prefix.setAbility(a);
            }else if(num>3){
                prefix.setLevel("t2");
                prefix.setName("");
                a.setStrength(0);
                prefix.setAbility(a);
            }else{
                prefix.setLevel("t3");
                prefix.setName("不趁手的");
                a.setStrength(-1);
                prefix.setAbility(a);
            }
        }
        return prefix;
    }

}
